package xiangmu.schoolpaper.controller.bingo.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xiangmu.schoolpaper.pojo.VO.SystemAllScoreAndSuggestByStudentAccountVO;
import xiangmu.schoolpaper.pojo.VO.SystemOneScoreVO;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.AdminDataListService;

@RestController
@RequestMapping("/system/score")
@Slf4j
@Tag(name = "管理员端——4数据管理——4评分管理")
public class SystemScoreManagementController {
    @Autowired
    private AdminDataListService adminDataListService;

    /*
        评分管理
    */
    // 列表
    @GetMapping("/get-all-papers-score-by-conditions")
    @Operation(summary = "1评分管理——获取所有符合筛选条件的评分数据")
    public Result<IPage<SystemOneScoreVO>> allPaperScore(
            @RequestParam(defaultValue = "1") Integer currentPage,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) Integer facultyId,
            @RequestParam(required = false) Integer graduationYear,
            @RequestParam(required = false) String studentAccount,
            @RequestParam(required = false) String paperTitle
    ) {
        log.info("返回所有符合筛选条件的评分数据");
        IPage<SystemOneScoreVO> pageData = adminDataListService.allPaperScore(currentPage, pageSize, facultyId, graduationYear, studentAccount, paperTitle);
        return Result.success(pageData);
    }

    // 个人分数详情
    @GetMapping("/get-paper-score-by-student-account")
    @Operation(summary = "2评分管理——根据学生的id获取学生详细评分信息")
    public Result<SystemAllScoreAndSuggestByStudentAccountVO> getByStudentAccount(@RequestParam String studentAccount) {
        log.info("根据学生的id返回学生论文信息");
        SystemAllScoreAndSuggestByStudentAccountVO data = adminDataListService.getByStudentAccount(studentAccount);
        if (data == null || CollectionUtils.isEmpty(data.getFactors())) {
            return Result.error("未查询到该学生的论文评分信息");
        }
        return Result.success(data);
    }
}
